<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app"></div>
    <script src="../src/react.js"></script>
    <script src="../src/react-dom.js"></script>
    <script src="../src/babel.js"></script>
    <script type="text/babel">

        let n = 0

       function fn(){
            console.log('+++++');
            n +=1
        }

        class Onec extends React.Component{
            constructor(){
                super()
                this.state={
                    nn:0
                }
                this.fn2 = this.fn2.bind(this)
            }
            fn2(){
                console.log('------2');
                this.setState({
                    nn:2
                })
            }
            fn3 =()=>{
                console.log('------3');
                this.setState({
                    nn:3
                })
            }
            fn4(m){
                console.log('------4',this);
                this.setState({
                    nn:m
                })
            }
            fn5 =(m)=>{
                console.log('------5');
                this.setState({
                    nn:m
                })
            }
            render(){
                return (
                    <div>
                        <p>{this.state.nn}</p> 
                        <button onClick={this.fn2}>coc2</button><br></br>
                        <button onClick={this.fn3}>coc3</button> <br></br>
                        <button onClick={()=>this.fn4(4)}>coc4</button> <br></br>
                        <button onClick={()=>this.fn5(5)}>coc5</button> 
                     </div>
                )
            }
        }


        let element = (
                // <p>{n}</p> 
            //  <button onClick={fn}>coc1</button> <br></br>
             <Onec></Onec>
        )

        ReactDOM.render(
            element,
            document.getElementById("app")
        )

    </script>
</body>

</html>